package com.itheima.demo4tcp1;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo2 {
    public static void main(String[] args) throws Exception {
        //创建一个服务器
        ServerSocket ss = new ServerSocket(10086);
        //调用accept方法 阻塞
        Socket socket = ss.accept();
        //获取输入流
        InputStream is = socket.getInputStream();
        //包装输入流
        DataInputStream dis = new DataInputStream(is);
        //读取数据
        String data = dis.readUTF();
        System.out.println(data);
        Integer num = dis.readInt();
        System.out.println(num);

    }
}
